Skip to content

refactor(app): centralize sync query options#25941

Open
Hona wants to merge 5 commits intoanomalyco:devfrom
Hona:refactor/query-options
Open

refactor(app): centralize sync query options#25941
Hona wants to merge 5 commits intoanomalyco:devfrom
Hona:refactor/query-options

Conversation

@Hona
Copy link
Copy Markdown
Member

@Hona Hona commented May 6, 2026

Summary

  • add useQueryOptions() so app components request sync query options without choosing global vs directory SDKs directly
  • keep global-vs-directory SDK selection centralized on the existing global sync SDK cache
  • route key-only consumers through queryOptions.keys instead of importing individual key helpers

Testing

  • bun typecheck from packages/app
  • bun --conditions=browser -e "<paused providers query repro>"
  • pre-push bun turbo typecheck

@Hona Hona marked this pull request as ready for review May 8, 2026 05:42
@Hona Hona requested a review from adamdotdevin as a code owner May 8, 2026 05:42
Copilot AI review requested due to automatic review settings May 8, 2026 05:42
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the app’s global sync context to centralize construction of TanStack query options (and associated SDK selection) behind a new useQueryOptions() hook, so components no longer need to directly choose between global vs directory SDK clients.

Changes:

  • Add queryOptionsApi to GlobalSync and expose it via useQueryOptions().
  • Update components to consume query keys/options via useQueryOptions() (e.g., MCP refetch + sessions fetching indicators).
  • Refactor createChildStoreManager to accept query option factories instead of a directory SDK getter.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
packages/app/src/pages/layout/sidebar-workspace.tsx Switch session fetching indicator to use queryOptions.sessions(...).queryKey.
packages/app/src/context/global-sync/child-store.ts Replace getSdk(directory) with injected query option factories for per-directory queries.
packages/app/src/context/global-sync/child-store.test.ts Update test harness to provide queryOptions instead of getSdk.
packages/app/src/context/global-sync.tsx Introduce queryOptionsApi, wire it into child stores, and export useQueryOptions().
packages/app/src/components/status-popover-body.tsx Refetch MCP status using centralized query options rather than importing query key helpers.
packages/app/src/components/prompt-input.tsx Route agents/providers queries through centralized query options (removes direct global SDK usage).
packages/app/src/components/dialog-select-mcp.tsx Refetch MCP status using centralized query options rather than importing query key helpers.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +184 to +187
input.queryOptions.path(key),
input.queryOptions.mcp(key),
input.queryOptions.lsp(key),
input.queryOptions.providers(key),
Comment on lines +29 to +34
queryOptions: {
lsp: (directory: string) => ReturnType<typeof loadLspQuery>
mcp: (directory: string) => ReturnType<typeof loadMcpQuery>
path: (directory: string) => ReturnType<typeof loadPathQuery>
providers: (directory: string) => ReturnType<typeof loadProvidersQuery>
}
vcsCache: children.vcsCache.get(key),
loadLsp: () => {
void queryClient.fetchQuery(loadLspQuery(key, sdkFor(directory)))
void queryClient.fetchQuery(queryOptionsApi.lsp(key))
Comment on lines +88 to +93
const queryOptionsApi = {
globalConfig: () => loadGlobalConfigQuery(globalSDK.client),
projects: () => loadProjectsQuery(globalSDK.client),
providers: (directory: string | null) =>
loadProvidersQuery(directory, directory === null ? globalSDK.client : sdkFor(directory)),
path: (directory: string | null) =>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants